import instance from "./request.js";
 
//一般情况下，接口类型会放到一个文件
// 下面两个TS接口，表示要传的参数
interface ReqLogin {
    name: string
    paw: string
}
interface ReqStatus {
    id: string
    navStatus: string
}
 
 
// Res是返回的参数，T是泛型，需要自己定义，返回对数统一管理***
type Res<T> = Promise<ItypeAPI<T>>;
// 一般情况下响应数据返回的这三个参数，
// 但不排除后端返回其它的可能性，
interface ItypeAPI<T> {
    data: T,//请求的数据，用泛型
    msg: string | null // 返回状态码的信息，如请求成功等
    code: number //返回后端自定义的200，404，500这种状态码
}
 
 
// post请求 ，没参数
export const LogoutAPI = (): Res<null> => 
    instance.get("/sugrec?&prod=pc_his&from=pc_web&json=1&sid=61027_62325_62833_62967_63041_63059_63188_63194_63210_63243_63245_63247_63262&hisdata=%5B%7B%22time%22%3A1747359405%2C%22kw%22%3A%22csdn%22%2C%22fq%22%3A2%7D%2C%7B%22time%22%3A1747366896%2C%22kw%22%3A%22vite-env-.d.ts%20%E6%8A%A5%E9%94%99%22%2C%22fq%22%3A2%7D%2C%7B%22time%22%3A1747367024%2C%22kw%22%3A%22tsconfig.app.json%22%2C%22fq%22%3A2%7D%2C%7B%22time%22%3A1747367444%2C%22kw%22%3A%22tsconfig.json%E5%A4%A7%E6%8B%AC%E5%8F%B7%E6%8A%A5%E9%94%99%22%2C%22fq%22%3A2%7D%2C%7B%22time%22%3A1747373510%2C%22kw%22%3A%22tsconfig.app.json%20extends%20%E6%8A%A5%E9%94%99%22%2C%22fq%22%3A4%7D%2C%7B%22time%22%3A1747373888%2C%22kw%22%3A%22vue3%20tsconfig.app.json%20extends%20%E6%8A%A5%E9%94%99%22%2C%22fq%22%3A4%7D%2C%7B%22time%22%3A1747379037%2C%22kw%22%3A%22vite%20vue3%20tsconfig%2Cjson%20%E6%8A%A5%E9%94%99%22%2C%22fq%22%3A2%7D%2C%7B%22time%22%3A1747383622%2C%22kw%22%3A%22%E7%99%BE%E5%BA%A6%E7%BD%91%E7%9B%98%22%2C%22fq%22%3A2%7D%5D&_t=1747384987366&req=2&bs=3%E5%90%8D%E6%80%A7%E4%BE%B5%E5%AE%B3%E6%9C%AA%E6%88%90%E5%B9%B4%E4%BA%BA%E7%BD%AA%E7%8A%AF%E6%89%A7%E8%A1%8C%E6%AD%BB%E5%88%91&csor=0");
 
// post请求，有参数,如传用户名和密码
export const loginAPI = (data: ReqLogin): Res<string> =>
    instance.post("/api/test", data);
 
// post请求 ，没参数，但要路径传参
export const StatusAPI = (data: ReqStatus): Res<null> =>
    instance.post(`/productCategory?ids=${data.id}&navStatus=${data.navStatus}`);
 
 
//  get请求，没参数，
export const FlashSessionListApi = (): Res<null> =>
    instance.get("/flashSession/list");
 
// get请求，有参数，路径也要传参  (也可能直接在这写类型，不过不建议,大点的项目会维护一麻烦)
export const ProductCategoryApi = (params: { parentId: number }): any =>
    instance.get(`/productCategory/list/${params.parentId}`, { params });
 
// get请求，有参数，(如果你不会写类型也可以使用any,不过不建议,因为用了之后 和没写TS一样)
export const AdminListAPI = (params:any): any => 
    instance.get("/admin/list", { params });
 